package com.apes.pi.model;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * @author wuq
 * @create 2019-10-19 10:57
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = SenderParams.CONST_TABLE_NAME)
public class SenderParams extends BaseModel {
    public static final String CONST_TABLE_NAME = "pi_sender_params";

    @Id
    @Column(name = "id", nullable = false, length = 8)
    @Comment("发送方编码")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "发送方",padding = 8)
    private String id;

    @NotNull
    @ManyToOne
    @JoinColumn(name = "sender_id", referencedColumnName="id")
    @Comment("连接器编码")
    private Sender sender;

    @Column(name = "name", nullable = false, length = 200)
    @Comment("发送方名称")
    private String name;

    @Column(name = "type", nullable = false, length = 200)
    @Comment("参数类型")
    private String type; // 参数类型（content-type, appKey, url...）

    @Column(name = "value", nullable = false, length = 2000)
    @Comment("值")
    private String value;   // 值

}
